<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Inserts multiple documents into this collection</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongocollection.aggregatecursor.html">« MongoCollection::aggregateCursor</a></li>
      <li style="float: right;"><a href="mongocollection.construct.html">MongoCollection::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongocollection.html">MongoCollection</a></li>
    <li>Inserts multiple documents into this collection</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongocollection.batchinsert" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCollection::batchInsert</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoCollection::batchInsert</span> &mdash; <span class="dc-title">Inserts multiple documents into this collection</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocollection.batchinsert-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoCollection::batchInsert</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$a</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code><span class="initializer"> = array()</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongocollection.batchinsert-parameters">
  <h3 class="title">Parameters</h3>    
  <p class="para">
   <dl>

    
     <dt>

      <code class="parameter">a</code>
     </dt>

     <dd>

      <p class="para">
       An array of arrays or objects. If any objects are used, they may not have
       protected or private properties.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        If the documents to insert do not have an <code class="literal">_id</code> key or
        property, a new <a href="class.mongoid.html" class="classname">MongoId</a> instance will be created
        and assigned to it. See <span class="function"><a href="mongocollection.insert.html" class="function">MongoCollection::insert()</a></span> for
        additional information on this behavior.
       </p>
      </p></blockquote>
     </dd>

       
    
     <dt>

      <code class="parameter">options</code>
     </dt>

     <dd>

      <p class="para">
       An array of options for the batch of insert operations. Currently
       available options include:
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <code class="literal">&quot;continueOnError&quot;</code>
         </p>
         <p class="para">
          Boolean, defaults to <strong><code>false</code></strong>. If set, the database will not stop
          processing a bulk insert if one fails (eg due to duplicate IDs).
          This makes bulk insert behave similarly to a series of single
          inserts, except that calling <span class="function"><a href="mongodb.lasterror.html" class="function">MongoDB::lastError()</a></span>
          will have an error set if any insert fails, not just the last one.
          If multiple errors occur, only the most recent will be reported by
          <span class="function"><a href="mongodb.lasterror.html" class="function">MongoDB::lastError()</a></span>.
         </p>
         <blockquote class="note"><p><strong class="note">Note</strong>: 
          <p class="para">
           Please note that <code class="literal">continueOnError</code> affects errors
           on the database side only. If you try to insert a document that has
           errors (for example it contains a key with an empty name), then the
           document is not even transferred to the database as the driver
           detects this error and bails out.
           <code class="literal">continueOnError</code> has no effect on errors detected
           in the documents by the driver.
          </p>
         </p></blockquote>
        </li>
        <li class="listitem"><p class="para"><code class="literal">&quot;fsync&quot;</code></p><p class="para">Boolean, defaults to <strong><code>false</code></strong>. If journaling is enabled, it works exactly like <code class="literal">&quot;j&quot;</code>. If journaling is not enabled, the write operation blocks until it is synced to database files on disk. If <strong><code>true</code></strong>, an acknowledged insert is implied and this option will override setting <code class="literal">&quot;w&quot;</code> to <code class="literal">0</code>.</p><blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">If journaling is enabled, users are strongly encouraged to use the <code class="literal">&quot;j&quot;</code> option instead of <code class="literal">&quot;fsync&quot;</code>. Do not use <code class="literal">&quot;fsync&quot;</code> and <code class="literal">&quot;j&quot;</code> simultaneously, as that will result in an error.</span></p></blockquote></li>
        <li class="listitem"><p class="para"><code class="literal">&quot;j&quot;</code></p><p class="para">Boolean, defaults to <strong><code>false</code></strong>. Forces the write operation to block until it is synced to the journal on disk. If <strong><code>true</code></strong>, an acknowledged write is implied and this option will override setting <code class="literal">&quot;w&quot;</code> to <code class="literal">0</code>.</p><blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">If this option is used and journaling is disabled, MongoDB 2.6+ will raise an error and the write will fail; older server versions will simply ignore the option.</span></p></blockquote></li>
        <li class="listitem"><p class="para"><code class="literal">&quot;socketTimeoutMS&quot;</code></p><p class="para">This option specifies the time limit, in milliseconds, for socket communication. If the server does not respond within the timeout period, a <a href="class.mongocursortimeoutexception.html" class="classname">MongoCursorTimeoutException</a> will be thrown and there will be no way to determine if the server actually handled the write or not. A value of <code class="literal">-1</code> may be specified to block indefinitely. The default value for <a href="class.mongoclient.html" class="classname">MongoClient</a> is <code class="literal">30000</code> (30 seconds).</p></li>
        <li class="listitem"><p class="para"><code class="literal">&quot;w&quot;</code></p><p class="para">See <a href="mongo.writeconcerns.html" class="link">Write Concerns</a>. The default value for <a href="class.mongoclient.html" class="classname">MongoClient</a> is <code class="literal">1</code>.</p></li>
        <li class="listitem"><p class="para"><code class="literal">&quot;wTimeoutMS&quot;</code></p><p class="para">This option specifies the time limit, in milliseconds, for <a href="mongo.writeconcerns.html" class="link">write concern</a> acknowledgement. It is only applicable when <code class="literal">&quot;w&quot;</code> is greater than <code class="literal">1</code>, as the timeout pertains to replication. If the write concern is not satisfied within the time limit, a <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> will be thrown. A value of <code class="literal">0</code> may be specified to block indefinitely. The default value for <a href="class.mongoclient.html" class="classname">MongoClient</a> is <code class="literal">10000</code> (ten seconds).</p></li>
       </ul>
      </p>
      <p class="para">
       The following options are deprecated and should no longer be used:
       <ul class="itemizedlist">
        <li class="listitem"><p class="para"><code class="literal">&quot;safe&quot;</code></p><p class="para">Deprecated. Please use the <a href="mongo.writeconcerns.html" class="link">write concern</a> <code class="literal">&quot;w&quot;</code> option.</p></li>
        <li class="listitem"><p class="para"><code class="literal">&quot;timeout&quot;</code></p><p class="para">Deprecated alias for <code class="literal">&quot;socketTimeoutMS&quot;</code>.</p></li>
        <li class="listitem"><p class="para"><code class="literal">&quot;wtimeout&quot;</code></p><p class="para">Deprecated alias for <code class="literal">&quot;wTimeoutMS&quot;</code>.</p></li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocollection.batchinsert-returnvalues">
  <h3 class="title">Return Values</h3>  
  <p class="para">
   If the <code class="literal">w</code> parameter is set to acknowledge the write,
   returns an associative array with the status of the inserts (&quot;ok&quot;) and any
   error that may have occurred (&quot;err&quot;).  Otherwise, returns <strong><code>true</code></strong> if the
   batch insert was successfully sent, <strong><code>false</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongocollection.batchinsert-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws <a href="class.mongoexception.html" class="classname">MongoException</a> if any inserted documents are
   empty or if they contains zero-length keys. Attempting to insert an object
   with protected and private properties will cause a zero-length key error.
  </p>
  <p class="para">Throws <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> if the <code class="literal">&quot;w&quot;</code> option is set and the write fails.</p><p class="para">Throws <a href="class.mongocursortimeoutexception.html" class="classname">MongoCursorTimeoutException</a> if the <code class="literal">&quot;w&quot;</code> option is set to a value greater than one and the operation takes longer than <var class="varname">MongoCursor::$timeout</var> milliseconds to complete.  This does not kill the operation on the server, it is a client-side timeout. The operation in <var class="varname">MongoCollection::$wtimeout</var> is milliseconds.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongocollection.batchinsert-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongo 1.5.0</td>
       <td>
        <p class="para">
         Added the <code class="literal">&quot;wTimeoutMS&quot;</code> option, which replaces
         <code class="literal">&quot;wtimeout&quot;</code>. Emits <strong><code>E_DEPRECATED</code></strong>
         when <code class="literal">&quot;wtimeout&quot;</code> is used.
        </p>
        <p class="para">
         Added the <code class="literal">&quot;socketTimeoutMS&quot;</code> option, which replaces
         <code class="literal">&quot;timeout&quot;</code>. Emits <strong><code>E_DEPRECATED</code></strong>
         when <code class="literal">&quot;timeout&quot;</code> is used.
        </p>
        <p class="para">
         Emits <strong><code>E_DEPRECATED</code></strong> when <code class="literal">&quot;safe&quot;</code>
         is used.
        </p>
       </td>
      </tr>

      <tr>
       <td>PECL mongo 1.3.4</td>
       <td>Added <code class="literal">&quot;wtimeout&quot;</code> option.</td>
      </tr>

      <tr>
       <td>PECL mongo 1.3.0</td>
       <td>Added <code class="literal">&quot;w&quot;</code> option.</td>
      </tr>

      <tr>
       <td>PECL mongo 1.2.7</td>
       <td>Added <code class="literal">&quot;continueOnError&quot;</code> option.</td>
      </tr>

      <tr>
       <td>PECL mongo 1.0.9</td>
       <td>
        <p class="para">
         Added ability to pass integers to the <code class="literal">&quot;safe&quot;</code> option,
         which previously only accepted booleans.
        </p>
        <p class="para">
         Added <code class="literal">&quot;fsync&quot;</code> option.
        </p>
       </td>
      </tr>

      <tr>
       <td>PECL mongo 1.0.5</td>
       <td>Added <code class="parameter">options</code> parameter.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocollection.batchinsert-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-94">
   <p><strong>Example #1 <span class="function"><strong>MongoCollection::batchInsert()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    Batch insertion is a quick way to add many elements to the database at once
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$users&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">100</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$users</span><span style="color: #007700">[]&nbsp;=&nbsp;array(</span><span style="color: #DD0000">'username'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'user'</span><span style="color: #007700">.</span><span style="color: #0000BB">$i</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'i'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$mongo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$collection&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mongo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">my_db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">users</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">drop</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">batchInsert</span><span style="color: #007700">(</span><span style="color: #0000BB">$users</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$users&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">[</span><span style="color: #DD0000">'_id'</span><span style="color: #007700">].</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;populated&nbsp;with&nbsp;instanceof&nbsp;MongoId<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #0000BB">$users&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">sort</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'i'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br />foreach&nbsp;(</span><span style="color: #0000BB">$users&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$user</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">]);<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
4bf43ac68ead0e1971000000
4bf43ac68ead0e1971010000
4bf43ac68ead0e1971020000
...
string(5) &quot;user1&quot;
string(5) &quot;user2&quot;
string(5) &quot;user3&quot;
...
</pre></div>
   </div>
  </div>

  <div class="example" id="example-95">
   <p><strong>Example #2 <span class="function"><strong>MongoCollection::batchInsert()</strong></span> example with
   ignoring errors</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$con&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Mongo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$con</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">demo</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$doc1&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'_id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoId</span><span style="color: #007700">(</span><span style="color: #DD0000">'4cb4ab6d7addf98506010001'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'desc'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"ONE"</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">$doc2&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'_id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoId</span><span style="color: #007700">(</span><span style="color: #DD0000">'4cb4ab6d7addf98506010002'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'desc'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"TWO"</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">$doc3&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'_id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoId</span><span style="color: #007700">(</span><span style="color: #DD0000">'4cb4ab6d7addf98506010002'</span><span style="color: #007700">),&nbsp;</span><span style="color: #FF8000">//&nbsp;same&nbsp;_id&nbsp;as&nbsp;above<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'desc'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"THREE"</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">$doc4&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'_id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoId</span><span style="color: #007700">(</span><span style="color: #DD0000">'4cb4ab6d7addf98506010004'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'desc'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"FOUR"</span><span style="color: #007700">,<br />);<br /><br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">'c'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">batchInsert</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #0000BB">$doc1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$doc2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$doc3</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$doc4</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="color: #DD0000">'continueOnError'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #0000BB">$docs&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">();<br />foreach&nbsp;(</span><span style="color: #0000BB">$docs&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$doc</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$doc</span><span style="color: #007700">[</span><span style="color: #DD0000">'desc'</span><span style="color: #007700">]);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
string(3) &quot;ONE&quot;
string(3) &quot;TWO&quot;
string(4) &quot;FOUR&quot;
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocollection.batchinsert-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="mongocollection.insert.html" class="function" rel="rdfs-seeAlso">MongoCollection::insert()</a> - Inserts a document into the collection</span></li>
   <li class="member"><span class="function"><a href="mongocollection.update.html" class="function" rel="rdfs-seeAlso">MongoCollection::update()</a> - Update records based on a given criteria</span></li>
   <li class="member"><span class="function"><a href="mongocollection.find.html" class="function" rel="rdfs-seeAlso">MongoCollection::find()</a> - Queries this collection, returning a MongoCursor
  for the result set</span></li>
   <li class="member"><span class="function"><a href="mongocollection.remove.html" class="function" rel="rdfs-seeAlso">MongoCollection::remove()</a> - Remove records from this collection</span></li>
   <li class="member">MongoDB core docs on <a href="https://docs.mongodb.com/manual/tutorial/insert-documents/" class="link external">&raquo;&nbsp;insert</a>.</li>
  </ul>
 </div>


</div></div></div></body></html>